package com.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.ddd.wandemo.R;
import com.util.ToastUtil;

public class MyCardView extends FrameLayout {
    private Context mContext;
    private View mContentView;
    private LinearLayout mLlMenuDetail;

    public MyCardView(@NonNull Context context) {
        this(context,null);
    }

    public MyCardView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,-1);
    }

    public MyCardView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        mContentView = LayoutInflater.from(mContext).inflate(R.layout.view_menu_card, this, true);
        mContentView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO: 2019/1/24 jump to another activity
                ToastUtil.showToast("activity");
            }
        });
        //默认状态不可点击
        mContentView.setClickable(false);

        mLlMenuDetail = mContentView.findViewById(R.id.ll_menu_details);

    }

    public void setOnClickable(boolean clickable){
        mContentView.setSelected(clickable);
        mContentView.setClickable(clickable);
    }


    public void setMenuData(){
        // TODO: 2019/1/24 setMenuData
    }
}
